package com.tnovoselec.android.favorites.entity;

/**
 * Title: Android Framework - Favorites <br />
 * <br />
 * Copyright: Copyright (c) 2011 <br />
 * <br />
 * NTH Company: NTH d.o.o. <br />
 * <br />
 * 
 * Abstract class used to define is given object is valid.
 * 
 * @author Tomislav Novoselec
 * @version 1.0.0
 * @since 1.0.0
 */

public abstract class ValidEntity {

    private int id;

    public ValidEntity(int id) {
	super();
	this.id = id;
    }

    public ValidEntity() {
	super();
    }

    public int getId() {
	return id;
    }

    public void setId(int id) {
	this.id = id;
    }

    /**
     * If all the fields are correctly filled, the object will be valid.
     * 
     * @return boolean flag if object is valid
     */
    public abstract boolean isValid();

    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + (int) (id ^ (id >>> 32));
	return result;
    }

    @Override
    public boolean equals(Object obj) {
	if (this == obj) {
	    return true;
	}
	if (obj == null) {
	    return false;
	}
	if (getClass() != obj.getClass()) {
	    return false;
	}
	ValidEntity other = (ValidEntity) obj;
	if (id != other.id) {
	    return false;
	}
	return true;
    }

}
